let v = new Vue({
    el:'#app',
    data:{
        id:"",
        pageInfo:{}
    },
    methods:{
        findMyUser:function (pageNum,pageSize){
            axios({
                url:`user/findMyUser/${pageNum}/${pageSize}/${this.id}`
            }).then(response=>{
                this.pageInfo = response.data.data;
            }).catch(error=>{
                layer.msg(error.message);
            })
        },
        toDetail:function (id){
            sessionStorage.setItem("userId",id);
        },
        unfollow:function (id){
            axios({
                url:`user/changeFocused`,
                method: "PUT",
                data:{
                    "focus":false,
                    "userId":id
                }
            }).then(response=>{
                if (response.data.flag){
                    layer.msg("取关成功")
                    //刷新页面
                    this.findMyUser(1,5);
                }
            }).catch(error=>{
                layer.msg(error.message);
            })
        }
    },
    created:function (){
        //从session中取出id
        let loginUser = sessionStorage.getItem("loginUser");
        loginUser = JSON.parse(loginUser);//转换成js对象
        this.id = loginUser.id;
        this.findMyUser(1,5);
    }
});